<?php
	include_once("DataProvider.php");
	include_once("../DTO/taiKhoanAdminDTO.php");
	
	class taiKhoanAdminDAO
	{
		public $sql = "";
		var $taiKhoanAdminDTO;
		function __construct()
		{
			return $this->taiKhoanAdminDTO = new taiKhoanAdminDTO();
		}
		
		public function xuLyDangNhapAdmin()
		{
			$username = $_POST["txtUser"];
			$password = $_POST["txtPass"];
			$sql = "select * from taiKhoan where idAdmin = '". $username ."' and matKhau = '".$password."'";
			$result = DataProvider::ExecuteQuery($sql);
			$num = mysql_num_rows($result);
			return $num;
		}
		
		public function taoSessionAdmin()
		{
			$username = $_POST["txtUser"];
			$password = $_POST["txtPass"];
			$sql = "select * from taiKhoan where idAdmin = '". $username ."' and matKhau = '".$password."'";
			$result = DataProvider::ExecuteQuery($sql);
			$member = mysql_fetch_array($result);
			$_SESSION["admin"] = $member["idAdmin"];
			return $_SESSION["admin"];
		}
		
		function dangXuatAdmin()
		{
			return session_destroy();
		}
		
	}
?>